package com.example.lynandroid.control;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsAnimationCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.List;

public class KeyBoardController11 implements IKeyBoardController {

    private Context mContext;
    private View emojiView; // 表情面板对应的View
    private View commonWordsView; // 常用语面板对应的View
    private View listView; // 键盘弹起时被往上顶的布局对应的View
    private View boardView; // 表情面板和常用语面板的父布局
    private float boardHeight; // 表情面板和常用语面板的最大高度
    private int curState = BottomState.SHOW_DEFAULT;

    public KeyBoardController11(Context mContext, View emojiView, View commonWordsView, View listView, View boardView, float boardHeight) {
        this.mContext = mContext;
        this.emojiView = emojiView;
        this.commonWordsView = commonWordsView;
        this.listView = listView;
        this.boardView = boardView;
        this.boardHeight = boardHeight;
        initCompat();
    }

    private void initCompat() {
        ViewCompat.setOnApplyWindowInsetsListener(listView, new OnApplyWindowInsetsListener() {
            @Override
            public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                boolean isKeyBoardShow = insets.isVisible(WindowInsetsCompat.Type.ime());
                int keyBoardHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
                return insets;
            }
        });
//        ViewCompat.setWindowInsetsAnimationCallback(listView, new WindowInsetsAnimationCompat.Callback(listView) {
//            @NonNull
//            @Override
//            public WindowInsetsCompat onProgress(@NonNull WindowInsetsCompat insets, @NonNull List<WindowInsetsAnimationCompat> runningAnimations) {
//                return insets;
//            }
//        });
        WindowInsetsCompat windowInsetsCompat = ViewCompat.getRootWindowInsets(listView);
        boolean isKeyBoardShow = windowInsetsCompat.isVisible(WindowInsetsCompat.Type.ime());
        int keyBoardHeight = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.ime()).bottom;
    }

    public void changeState(@BottomState int state) {
        if (state == curState) {
            return;
        }
        this.curState = state;
        switch (state) {

        }
    }

}
